package com.jh.rq;

import java.util.Map;
import java.util.TreeMap;

/**
 * @author Li
 * @Date 2023/4/20 14:53
 */
public class StatisticsChar {
    public static void main(String[] args) {
        String str = "aabbbaceeafdsdf";
        TreeMap<Character, Integer> freqMap = new TreeMap<>();

        for (char c : str.toCharArray()) {
            freqMap.put(c, freqMap.getOrDefault(c, 0) + 1);
        }

        for (Map.Entry<Character, Integer> entry : freqMap.entrySet()) {
            System.out.print(entry.getKey() + "(" + entry.getValue() + ")"+" ");
        }
    }
}
